/*
 * opencvtests.cpp
 *
 *  Created on: 16.09.2010
 *      Author: pasha
 */

#include <QtGui/qpixmap.h>
#include <QtGui/qimage.h>
#include <QtGui/qgraphicsview.h>
#include <QtGui/qwidget.h>
#include <QtGui/qgridlayout.h>
#include <QtGui/qlayout.h>
#include <QtGui/qlayoutitem.h>
#include <QtGui/qapplication.h>
#include <QtGui/qgraphicsitem.h>
#include <QtGui/qgraphicswidget.h>
#include <QtGui/qlabel.h>
#include <QtGui/qevent.h>
#include <cv.h>
#include <math.h>
#include <highgui.h>
#include <iostream>
using namespace cv;
using namespace std;
int mmmain(int argc, char** argv)
{
	QApplication myapp(argc, argv);
	Mat image = imread("/home/pasha/foto1638.jpg", 1);
	Mat cvtimage;
	Mat grayImage;
	cvtColor(image, grayImage, CV_BGR2GRAY);
	Mat features;
	vector<Point2f> stars;
	image.setTo(CV_RGB(0,0,0));
	cvtColor(image, cvtimage, CV_BGR2RGBA);
	goodFeaturesToTrack(grayImage, stars, 1000, 0.1, 10);
	cout << stars.size();
	for (size_t i = 0; i < stars.size(); i++)
	{
		// draw the circle center
		circle(cvtimage, stars[i], 2, Scalar(0, 255, 0), -1, 8, 0);
	}
	QImage myimage(cvtimage.data, image.cols, image.rows, QImage::Format_RGB32);
	QGraphicsScene *scene = new QGraphicsScene();
	QPixmap pixmap = QPixmap::fromImage(myimage);
	scene->setSceneRect(0, 0, image.cols, image.rows);
	scene->addPixmap(pixmap);
	QGraphicsView mywindow;
	mywindow.setScene(scene);
	mywindow.scale(0.8, 0.8);
	mywindow.show();
	myapp.exec();
}
